import React, { Component } from 'react';
import {CSSTransition} from 'react-transition-group';

class CSSDemo extends Component {
  constructor(props) {
    super(props);
    this.state = {
      show: false
    };
  }
  fnClick = () => {
    this.setState({show: !this.state.show})
  }
  render() { 
    return (
      <div>
        <button onClick={this.fnClick}>star</button>
        <CSSTransition
          classNames="fade"
          in={this.state.show}
          timeout={500}
          unmountOnExit
        >
          <div style={{width: 200, height: 200, background: 'orange'}}></div>
        </CSSTransition>
      </div>
    );
  }
}
 
export default CSSDemo;